package controllayer;
import modellayer.*;


/**
 * The class PersonCtrl is to take input from and perform the actions requested from the
 * class SalesUI. These actions are performed on the class ClerkContainer in the modellayer.
 * 
 * @author Allan Eriksen, Christian Stidsborg, Andreas Rye, Casper Madsen, Stefan Bols 
 * @version 051213
 */
public class PersonCtrl
{
	private static PersonCtrl instance;
    private ClerkContainer clerkCon;

    /**
     * This is the constucter for PersonCtrl which calls the ClerkContainer singleton method
     */
    private PersonCtrl()
    {
        clerkCon = ClerkContainer.getInstance(); 
    }
    
    public static PersonCtrl getInstance() {
    	if (instance==null) {
    		instance = new PersonCtrl();
    	}
    	
    	return instance;
    }
    
    /**
     * This method returns a clerk object
     * @param int clerkNo
     * @return Clerk c
     */
    public Clerk getClerk(String clerkNo)
    {
        Clerk c;
        c = clerkCon.getClerk(clerkNo);
        return c;
    }
    
    /**
     * This method returns the field firstName of a clerk object
     * @param Clerk clerkObj
     * @return String firstName
     */
    public String getClerkFirstName(Clerk clerkObj)
    {
        return clerkObj.getFirstName();
    }
    
    /**
     * This method returns the full name for a clerk retrieved by its clerkNo
     * @param int clerkNo
     * @return String Full name
     */
    public String getClerkFullname(String clerkNo)
    {
        Clerk c = getClerk(clerkNo);
        return c.getFirstName() + " " + c.getLastName();
    }
}
